#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020/4/10 09:42
# @Author  : yangdy
# @Email   : yangdy@egu360.com
# @File    : 151. 翻转字符串里的单词.2020-04-10.py
# @Software: PyCharm

__author__ = 'yangdy'


class Solution:
    def reverseWords(self, s: str) -> str:
        #
        # arr = []
        # for si in s.strip().split(' '):
        #     if si:
        #         arr.append(si)
        # arr.reverse()
        # return ' '.join(arr)
        return ' '.join(s.strip().split()[::-1])


solve = Solution()
ss1 = '  the   sky is  blue'
print(solve.reverseWords(ss1))

ss2 = '  hello world!   '
print(solve.reverseWords(ss2))

ss3 = 'a good   example'
print(solve.reverseWords(ss3))
